//
//  YJBTradeExplainToolsView.m
//  YunJiaBaoFirst
//
//  Created by 腾云小白龍 on 16/7/31.
//  Copyright © 2016年 腾云小白龍. All rights reserved.
//

#import "YJBTradeExplainToolsView.h"

@implementation YJBTradeExplainToolsView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
    }
    
    return self;
}

-(void)initView{
    CGFloat imgViewH = 25;
    CGFloat imgViewW = 20;
    CGFloat labelH   = 18;
    CGFloat margin   = SCREEN_WIDTH/5;
    CGFloat fontSize = 12;
    CGFloat x = (SCREEN_WIDTH / 5 - imgViewW)/2;
    UIImageView *accountImgView  = ({
        UIImageView *imgView =[[UIImageView alloc]initWithFrame:CGRectMake(x, 5, imgViewW, imgViewH)];
        imgView.image = [UIImage imageNamed:@"tradeType"];
        imgView.contentMode = UIViewContentModeScaleAspectFit;
        imgView;
    });
    [self addSubview:accountImgView];
    
    UILabel *accountLabel = ({
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(accountImgView.frame) - 2, SCREEN_WIDTH / 5, labelH)];
        label.text = @"运力品种";
        label.textColor = [UIColor grayColor];
        label.font = [UIFont systemFontOfSize:fontSize];
        label.textAlignment = NSTextAlignmentCenter;
        label;
    });
    [self addSubview:accountLabel];
    
    self.tradeTypeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH / 5, 50)];
    [self.tradeTypeBtn setTitle:@"" forState:UIControlStateNormal];
    [self.tradeTypeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.tradeTypeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    
    
    
    UIImageView *dealImgView  = ({
        UIImageView *imgView =[[UIImageView alloc]initWithFrame:CGRectMake(x + margin, 5, imgViewW, imgViewH)];
        imgView.image = [UIImage imageNamed:@"dealRule"];
        imgView.contentMode = UIViewContentModeScaleAspectFit;
        imgView;
    });
    [self addSubview:dealImgView];
    
    UILabel *dealLabel = ({
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(margin, CGRectGetMaxY(accountImgView.frame) - 2, SCREEN_WIDTH / 5, labelH)];
        label.text = @"交易规则";
        label.textColor = [UIColor grayColor];
        label.font = [UIFont systemFontOfSize:fontSize];
        label.textAlignment = NSTextAlignmentCenter;
        label;
    });
    [self addSubview:dealLabel];
    
    
    self.dealRuleBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 5, 0, SCREEN_WIDTH / 5, 50)];
    [self.dealRuleBtn setTitle:@"" forState:UIControlStateNormal];
    [self.dealRuleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.dealRuleBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    
    
    UIImageView *recordImgView  = ({
        UIImageView *imgView =[[UIImageView alloc]initWithFrame:CGRectMake(x + margin*2, 5, imgViewW, imgViewH)];
        imgView.image = [UIImage imageNamed:@"goodsStandard"];
        imgView.contentMode = UIViewContentModeScaleAspectFit;
        imgView;
    });
    [self addSubview:recordImgView];
    
    UILabel *recordLabel = ({
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(margin*2, CGRectGetMaxY(accountImgView.frame) - 2, SCREEN_WIDTH / 5, labelH)];
        label.text = @"货物标准";
        label.textColor = [UIColor grayColor];
        label.font = [UIFont systemFontOfSize:fontSize];
        label.textAlignment = NSTextAlignmentCenter;
        label;
    });
    [self addSubview:recordLabel];
    
    self.goodsStandardBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 5 * 2, 0, SCREEN_WIDTH / 5, 50)];
    [self.goodsStandardBtn setTitle:@"" forState:UIControlStateNormal];
    [self.goodsStandardBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.goodsStandardBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    
    
    
    UIImageView *explainImgView  = ({
        UIImageView *imgView =[[UIImageView alloc]initWithFrame:CGRectMake(x + margin*3, 5, imgViewW, imgViewH)];
        imgView.image = [UIImage imageNamed:@"loadCarRule"];
        imgView.contentMode = UIViewContentModeScaleAspectFit;
        imgView;
    });
    [self addSubview:explainImgView];
    
    UILabel *explainLabel = ({
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(margin*3, CGRectGetMaxY(accountImgView.frame) - 2, SCREEN_WIDTH / 5, labelH)];
        label.text = @"提车规则";
        label.textColor = [UIColor grayColor];
        label.font = [UIFont systemFontOfSize:fontSize];
        label.textAlignment = NSTextAlignmentCenter;
        label;
    });
    [self addSubview:explainLabel];
    
    self.loadCarRuleBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 5 * 3, 0, SCREEN_WIDTH / 5, 50)];
    [self.loadCarRuleBtn setTitle:@"" forState:UIControlStateNormal];
    [self.loadCarRuleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.loadCarRuleBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    
    
    UIImageView *supplierImgView  = ({
        UIImageView *imgView =[[UIImageView alloc]initWithFrame:CGRectMake(x + margin*4, 5, imgViewW, imgViewH)];
        imgView.image = [UIImage imageNamed:@"supplier"];
        imgView.contentMode = UIViewContentModeScaleAspectFit;
        imgView;
    });
    [self addSubview:supplierImgView];
    
    UILabel *supplierLabel = ({
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(margin*4, CGRectGetMaxY(accountImgView.frame) - 2, SCREEN_WIDTH / 5, labelH)];
        label.text = @"运力供应商";
        label.textColor = [UIColor grayColor];
        label.font = [UIFont systemFontOfSize:fontSize];
        label.textAlignment = NSTextAlignmentCenter;
        label;
    });
    [self addSubview:supplierLabel];
    
    self.supplierBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 5 * 4, 0, SCREEN_WIDTH / 5, 50)];
    [self.supplierBtn setTitle:@"" forState:UIControlStateNormal];
    [self.supplierBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.supplierBtn.titleLabel.font = [UIFont systemFontOfSize:14];

    UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, self.height-1, SCREEN_WIDTH, 1)];
    lineView.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:lineView];
    
    [self addSubview:self.tradeTypeBtn];
    [self addSubview:self.dealRuleBtn];
    [self addSubview:self.goodsStandardBtn];
    [self addSubview:self.loadCarRuleBtn];
    [self addSubview:self.supplierBtn];

    
}
@end
